package edu.hhu.wifispark.entry;

import java.util.List;

import com.jfinal.plugin.activerecord.Model;

public class Customer extends Model<Customer>{

	private static final long serialVersionUID = 1L;
	public final static Customer dao = new Customer();
	
	public List<Customer> FindToday(){
		String sql = "SELECT mac, SUM(freq) AS freq, SUM(freq * avetime) AS totaltime, SUBSTRING_INDEX(GROUP_CONCAT(period ORDER BY atime DESC),',',1) as period FROM customer GROUP BY mac";
		System.out.println(sql);
		return find(sql);
	}
	
//	public List<Customer> FindPeriod(String mac){
//		String sql = "SELECT mac, period FROM customer WHERE mac = '" + mac + "' ORDER BY atime DESC LIMIT 1";
//		System.out.println(sql);
//		return find(sql);
//	}
}
